package io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.stream.Collectors;

public class BufferedInputFile1 {
    static String read(String filename) {
        try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
          return   br.lines().collect(Collectors.joining("\n\n"));


        } catch (Exception e) {

            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) throws IOException {
        String s = read("D:\\test\\java\\src\\main\\java\\io\\BufferedInputFile1.java");
        System.out.println(s);

        System.out.println("===ds=f=ds=f=ds=fds==");

        StringReader stringReader = new StringReader(s);

        int len = -1;

        while (((len = stringReader.read())) != -1) {

            System.out.print((char)len);


        }
        System.out.println("sdf+++++++++++++++++++++++++++");



    }
}
